package CoreNRMSystem;

/**
 * Generated from IDL union "DestinationTypeType".
 *
 * @author JacORB IDL compiler V 2.3.0, 17-Feb-2007
 * @version generated at 2013-5-20 22:07:19
 */

public final class DestinationTypeTypeHelper
{
	private static org.omg.CORBA.TypeCode _type;
	public static void insert (final org.omg.CORBA.Any any, final CoreNRMSystem.DestinationTypeType s)
	{
		any.type(type());
		write( any.create_output_stream(),s);
	}

	public static CoreNRMSystem.DestinationTypeType extract (final org.omg.CORBA.Any any)
	{
		return read(any.create_input_stream());
	}

	public static String id()
	{
		return "IDL:CoreNRMSystem/DestinationTypeType:1.0";
	}
	public static DestinationTypeType read (org.omg.CORBA.portable.InputStream in)
	{
		DestinationTypeType result = new DestinationTypeType ();
		CoreNRMSystem.DestinationTypeChoiceType disc = CoreNRMSystem.DestinationTypeChoiceType.from_int(in.read_long());
		switch (disc.value ())
		{
			case CoreNRMSystem.DestinationTypeChoiceType._NatureOfAddressChoice:
			{
				byte[] _var;
				_var = CoreNRMSystem.NatureOfAddressTypeHelper.read(in);
				result.natureOfAddress (_var);
				break;
			}
			case CoreNRMSystem.DestinationTypeChoiceType._DestTypeChoice:
			{
				CoreNRMSystem.DestType _var;
				_var=CoreNRMSystem.DestTypeHelper.read(in);
				result.dest (_var);
				break;
			}
		}
		return result;
	}
	public static void write (org.omg.CORBA.portable.OutputStream out, DestinationTypeType s)
	{
		out.write_long (s.discriminator().value ());
		switch (s.discriminator().value ())
		{
			case CoreNRMSystem.DestinationTypeChoiceType._NatureOfAddressChoice:
			{
				CoreNRMSystem.NatureOfAddressTypeHelper.write(out,s.natureOfAddress ());
				break;
			}
			case CoreNRMSystem.DestinationTypeChoiceType._DestTypeChoice:
			{
				CoreNRMSystem.DestTypeHelper.write(out,s.dest ());
				break;
			}
		}
	}
	public static org.omg.CORBA.TypeCode type ()
	{
		if (_type == null)
		{
			org.omg.CORBA.UnionMember[] members = new org.omg.CORBA.UnionMember[2];
			org.omg.CORBA.Any label_any;
			label_any = org.omg.CORBA.ORB.init().create_any ();
			CoreNRMSystem.DestinationTypeChoiceTypeHelper.insert(label_any, CoreNRMSystem.DestinationTypeChoiceType.NatureOfAddressChoice);
			members[0] = new org.omg.CORBA.UnionMember ("natureOfAddress", label_any, CoreNRMSystem.NatureOfAddressTypeHelper.type(),null);
			label_any = org.omg.CORBA.ORB.init().create_any ();
			CoreNRMSystem.DestinationTypeChoiceTypeHelper.insert(label_any, CoreNRMSystem.DestinationTypeChoiceType.DestTypeChoice);
			members[1] = new org.omg.CORBA.UnionMember ("dest", label_any, CoreNRMSystem.DestTypeHelper.type(),null);
			 _type = org.omg.CORBA.ORB.init().create_union_tc(id(),"DestinationTypeType",CoreNRMSystem.DestinationTypeChoiceTypeHelper.type(), members);
		}
		return _type;
	}
}
